
from dingtalkchatbot.chatbot import DingtalkChatbot

class Chatbot(object):
    def __init__(self, options):
        self.client = DingtalkChatbot(options.webhook)
        self.options = options
        self.logger = options.logger

    def sendmsg(self, msg, tag = '', iscode=False):
        msg = '{}==>message:{}'.format(tag, msg)
        if self.logger:
            self.logger.debug(msg)

        if iscode:
            res = self.client.send_text(msg, at_mobiles=self.options.atMobiles)
        else:
            res = self.client.send_text(msg)
        return res


